Repository navigation
fix(invoke): accept --bearer-token for harness invoke - #2742
Open
scooteronce wants to merge 2 commits into
Open
scooteronce wants to merge 2 commits into
scooteronce wants to merge 2 commits into
Conversation
maxrabin
reviewed
Nov 3, 2026
maxrabin
left a comment
There was a problem hiding this comment.
Tested end to end against a real CUSTOM_JWT harness (Entra ID) on macOS with every AWS credential source removed: --bearer-token file://… returned a reply. The bearer auth works.
Two requests:
- Add a test that a non-DEFAULT
--qualifierreachesInvokeHarnesstogether with--bearer-token. harness invoke --id … --bearer-tokenstill callsGetHarness, so without AWS credentials it fails with a confusing credentials error. Consider rejecting that combination up front and pointing toinvoke --harness <arn>.
A CUSTOM_JWT harness could not be invoked without AWS credentials: --harness rejected --bearer-token, and the invoke always called GetHarness and signed with SigV4. invoke --harness <arn> now skips GetHarness, and a bearer token (from stdin or file://) is sent as Authorization: Bearer instead of a SigV4 signature.
scooteronce
force-pushed
the
fix/harness-invoke-bearer-token
branch
from
November 3, 2026 16:36
37ce966 to
5c50c8d
Compare
Without the ARN, harness invoke had to call GetHarness first, so a caller holding only a JWT failed with a confusing credentials error. The combination is now rejected up front with a pointer to 'agentcore invoke --harness <arn>'. Project harnesses still work, since their target credentials cover the lookup. Also covers a non-DEFAULT --qualifier reaching InvokeHarness with a bearer token.
Author
|
Thanks for testing this against a real harness. Both requests are addressed in eed9dbc:
|
maxrabin
approved these changes
Nov 4, 2026
maxrabin
left a comment
There was a problem hiding this comment.
Re-tested eed9dbcf merged with #2750 against a real CUSTOM_JWT harness, with no AWS credentials. --harness <arn> --bearer-token - works on DEFAULT and on a non-DEFAULT --qualifier. --id with a token is rejected up front, and an inline token is rejected. LGTM.
16 of 22 tasks
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
A CUSTOM_JWT harness could not be invoked without AWS credentials in v1 (a 0.x regression).
invoke --harnessrejected--bearer-token, and the harness invoke always calledGetHarnessand signedInvokeHarnesswith SigV4.harness invokeaccepts--bearer-tokenfrom stdin (-) or a file (file://<path>), following fix(cli): reject inline bearer tokens in credential flags #2567's convention. Inline values are rejected withSourceResolver.resolveSecret.agentcore invoke --harnesspicks up the flag.invoke --harness <arn>passes the ARN to the harness handler, so the invoke skipsGetHarness.createDataClientreplaces SigV4 with Smithy'ssmithy.api#httpBearerAuthscheme (HttpBearerAuthSigner). The SDK'sInvokeHarnessCommandand event-stream deserialization are unchanged. The client sendsAuthorization: Bearer <jwt>and never resolves AWS credentials.CoreClient.data()doesn't cache bearer clients, so a later SigV4 call can't reuse one.--bearer-tokenwithout--promptis rejected instead of opening the TUI, because the chat screen still callsGetHarness.Now this works with no AWS credentials:
Out of scope, follow-ups:
harness invoke --id <id> --bearer-tokenstill callsGetHarness, because the ID alone doesn't give the ARN.harness shellandruntime invokestill make a control-plane lookup before their bearer call.Related Issue
Closes #2741
Documentation PR
Not applicable.
command.mdis regenerated in this PR.Type of Change
Testing
How have you tested the change?
bun test. 4712 pass, 0 fail.bun run test:e2e, or explained why they are not applicable. I didn't run them: they need a deployed harness with a CUSTOM_JWT authorizer and an IdP token, which I don't have. Instead, I ran the built bundle under Node with every AWS credential source removed.echo <jwt> | node dist/index.js invoke --harness <arn> --bearer-token - --prompt helloreached the service and gotHarness not foundfor a placeholder ARN. Before this change, it failed with--bearer-token does not apply to a Harness.bun run typecheckbun run lint:checkbun run format:checkbun run buildsrc/assets/, I updated affected snapshots withbun test <test-file> --update-snapshotsand committed them. Not applicable.New tests:
src/core/factories.test.ts: the real data client sendsAuthorization: Bearerand no SigV4 headers, and doesn't call a credentials provider that throws. Without a token, the request is SigV4-signed.src/core/core.test.ts: bearer clients are never cached or reused for SigV4 callers.src/core/harness.test.ts: the token goes to the client config, not theInvokeHarnessinput.src/handlers/harness/invoke/invoke.test.tsx: the token is read from stdin and fromfile://. Inline tokens are rejected. Passing--bearer-tokenwithout--promptis rejected.src/handlers/project/invoke/index.test.tsx:--harness <arn> --bearer-token - --promptmakes only theInvokeHarnesscall, in the ARN's region.Checklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the
terms of your choice.